import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screen_util.dart';
import 'package:flutter/material.dart';
import 'package:study_online/entity/Remark.dart';
import 'package:study_online/global/colors.dart';
import 'package:study_online/global/myIcons.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.black26,
          title: Text('container'),
        ),
        body: RemarkItem(),
      ),
    );
  }
}

class RemarkItem extends StatefulWidget {
  RemarkItem({Key key, this.remark}) : super(key: key);
  Remark remark;

  @override
  _RemarkItemState createState() {
    return _RemarkItemState();
  }
}

class _RemarkItemState extends State<RemarkItem> {
  @override
  void initState() {
    super.initState();
    this._remark = widget.remark;
    print("##**" + _remark.toString());
  }

  @override
  void dispose() {
    super.dispose();
  }

  Remark _remark;

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(
      BoxConstraints(
          maxWidth: MediaQuery.of(context).size.width,
          maxHeight: MediaQuery.of(context).size.height),
      designSize: Size(1080, 2340),
    );
    return Container(
      width: ScreenUtil().screenWidth - ScreenUtil().setWidth(110),
      margin: EdgeInsets.only(top: ScreenUtil().setHeight(58)),
      child: Column(
        //mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              ClipOval(
                child: Image.network(
                    _remark == null
                        ? "https://img2.baidu.com/it/u=172917783,2425047487&fm=26&fmt=auto"
                        : _remark.photo,
                    width: ScreenUtil().setSp(80),
                    height: ScreenUtil().setSp(80),
                    fit: BoxFit.cover),
              ),
              SizedBox(width: ScreenUtil().setWidth(13)),
              Text(
                _remark == null ? 'wind' : _remark.nickName,
                style: TextStyle(
                  fontSize: ScreenUtil().setSp(46),
                  color: Colors.black45,
                ),
              ),
              Expanded(
                child: Align(
                  alignment: Alignment.bottomRight,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: [
                      _remark.score >= 1
                          ? Icon(Icons.star_rate_rounded,
                              color: AppColors.yellow,
                              size: ScreenUtil().setSp(60))
                          : Icon(Icons.star_outline_rounded,
                              color: AppColors.subtext,
                              size: ScreenUtil().setSp(60)),
                      _remark.score >= 2
                          ? Icon(Icons.star_rate_rounded,
                              color: AppColors.yellow,
                              size: ScreenUtil().setSp(60))
                          : Icon(Icons.star_outline_rounded,
                              color: AppColors.subtext,
                              size: ScreenUtil().setSp(60)),
                      _remark.score >= 3
                          ? Icon(Icons.star_rate_rounded,
                              color: AppColors.yellow,
                              size: ScreenUtil().setSp(60))
                          : Icon(Icons.star_outline_rounded,
                              color: AppColors.subtext,
                              size: ScreenUtil().setSp(60)),
                      _remark.score >= 4
                          ? Icon(Icons.star_rate_rounded,
                              color: AppColors.yellow,
                              size: ScreenUtil().setSp(60))
                          : Icon(Icons.star_outline_rounded,
                              color: AppColors.subtext,
                              size: ScreenUtil().setSp(60)),
                      _remark.score >= 5
                          ? Icon(Icons.star_rate_rounded,
                              color: AppColors.yellow,
                              size: ScreenUtil().setSp(60))
                          : Icon(Icons.star_outline_rounded,
                              color: AppColors.subtext,
                              size: ScreenUtil().setSp(60)),
                      SizedBox(width: ScreenUtil().setWidth(73)),
                      Image.asset(
                        'assets/img/three_dots.png',
                        height: ScreenUtil().setHeight(50),
                        fit: BoxFit.fitHeight,
                      ),
                    ],
                  ),
                ),
              )
            ],
          ),
          Container(
            margin: EdgeInsets.only(
                left: ScreenUtil().setWidth(98),
                top: ScreenUtil().setHeight(46)),
            child: Column(
              //mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Align(
                  child: Text(
                    _remark == null
                        ? '好拼,好拼,好评好拼,好拼,好评,好拼,好拼,好评,好拼,好拼,好评,好拼,好拼,好评'
                        : _remark.com,
                    style: TextStyle(
                      fontSize: ScreenUtil().setSp(46),
                      color: Colors.black,
                    ),
                  ),
                  alignment: Alignment.bottomLeft,
                ),
                SizedBox(height: ScreenUtil().setHeight(68)),
                Row(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Text(
                      _remark == null
                          ? '2020-05-07'
                          : _remark.time.substring(0, 10),
                      style: TextStyle(
                        fontSize: ScreenUtil().setSp(40),
                        color: AppColors.subtext,
                      ),
                    ),
                    Expanded(
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: [
                          IconButton(
                            icon: Icon(
                              Icons.thumb_up_alt_outlined,
                              size: ScreenUtil().setSp(75),
                              color: AppColors.subtext,
                            ),
                            onPressed: () {},
                          ),
                          SizedBox(width: ScreenUtil().setWidth(30)),
                          IconButton(
                            icon: Icon(
                              Icons.thumb_down_alt_outlined,
                              size: ScreenUtil().setSp(75),
                              color: AppColors.subtext,
                            ),
                            onPressed: () {},
                          ),
                          SizedBox(width: ScreenUtil().setWidth(30)),
                          IconButton(
                            icon: Icon(
                              MyIcons.remark,
                              size: ScreenUtil().setSp(75),
                              color: AppColors.subtext,
                            ),
                            onPressed: () {},
                          ),
                        ],
                      ),
                    )
                  ],
                )
              ],
            ),
          ),
        ],
      ),
    );
  }
}
